/*
 * LEDonti.c
 *
 *  Created on: Sep 14, 2013
 *      Author: Ricardo
 */


#include "LEDonti.h" 
#include "derivative.h" /* include peripheral declarations */


void init_leds();
void red_on();
void red_off();
void green_on();
void green_off();
void blue_on();
void blue_off();



void app_rgb_ledONTI_fsm(void)
{
	static unsigned char rgb_state = 0;
	
	switch(rgb_state)
	{
		case 0: /* RESET */
			/* All off */
			red_off();
			green_off();
			blue_off();
			rgb_state = 1;
			break;
		case 1: /* red on */
			red_on();
			green_off();
			blue_off();
			rgb_state = 2;
			break;
		case 2: /* green on */
			red_off();
			green_on();
			blue_off();
			rgb_state = 3;
			break;
		case 3: /* blue on */
			red_off();
			green_off();
			blue_on();
			rgb_state = 4;
			break;
		case 4: /* red + green */
			red_on();
			green_on();
			blue_off();
			rgb_state = 5;
			break;
		case 5: /* red + blue */
			red_on();
			green_off();
			blue_on();
			rgb_state = 6;
			break;
		case 6: /* green + blue */
			red_off();
			green_on();
			blue_on();
			rgb_state = 7;
			break;
		case 7: /* All on */
			red_on();
			green_on();
			blue_on();
			rgb_state = 1;
			break;
		default:
			/* Go to RESET */
			rgb_state = 0;
			break;
	}
}

void red_on(){
	RED_ON;
}

void red_off(){
	RED_OFF;
}

void green_on(){
	GREEN_ON;
}

void green_off(){
	GREEN_OFF;
}

void blue_on(){
	BLUE_ON;
}

void blue_off(){
	BLUE_OFF;
}



